package com.yzy.fly.type;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
public enum FlyComponentType {
    MODEL("model", "I"),
    INTERFACE("interface", "I"),
    CONTROLLER("controller", "I"),
    SERVICE("service", "I"),
    MAPPER("mapper", "I"),
    FUNCTION("function", "I"),
    UNKNOW("unknow", "I");
    @Setter
    @Getter
    private String type;
    @Setter
    @Getter
    private String value;

    FlyComponentType(String type, String value) {
        this.type = type;
        this.value = value;
    }

    public static FlyComponentType type(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        }
        FlyComponentType flyComponentType;
        try {
            flyComponentType = valueOf(type);
        } catch (IllegalArgumentException e) {
            log.warn(e.getMessage());
            flyComponentType = null;
        }
        return flyComponentType;
    }


}
